﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitView;

namespace YJKRevitWallModule.WallModule.CreateWall
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class DrawWallCmd : IExternalCommand
	{
		Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			if (Convert.ToInt32(commandData.Application.Application.VersionNumber) < 2014)
			{
				message = "此功能只在Revit2014及其以上版本可用。";
				return Autodesk.Revit.UI.Result.Failed;
			}
			CmdViewType types = (CmdViewType)11;
			if (SwitchView.SetUsableView(types, commandData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			Result result;
			try
			{
				result = new DrawWallManager(commandData).DrawWallLoop(DrawWallCmd.m_strWallFSType);
			}
			catch (Exception)
			{
				result = Autodesk.Revit.UI.Result.Failed;
			}
			return result;
		}

		public static string m_strWallFSType;
	}
}
